<!DOCTYPE html>
<html lang="zh">
<head>
    <th:block th:include="include :: header('文件上传')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <div class="form-group">
                        <label class="font-noraml">请上传模板文件（仅支持.jar文件格式）</label>
                        <div class="file-loading">
                            <input id="multipleFile" name="files" type="file" multiple>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js" />
<script th:inline="javascript">
    var prefix = ctx + "system/template";
    var instId = [[${instId}]];

    $(document).ready(function () {
        // 多文件上传
        $("#multipleFile").fileinput({
            uploadUrl: prefix + '/uploads/'+instId,
            uploadAsync: false,
            showCaption: true,  //input框是否显示
            showUpload: true,   //上传按钮是否显示
            showPreview: true, //预览区域
            showClose: false, //关闭按钮
            preferIconicPreview: true, // this will force thumbnails to display icons for following file extensions
            previewFileIconSettings: { // configure your icon file extensions
                'jar': '<i class="fa fa-file-code-o text-success"></i>'
            },
            previewFileExtSettings: { // configure the logic for determining icon file extensions
                'jar': function (ext) {
                    return ext.match(/(xls|xlsx)$/i);
                }
            },
            // previewFileIcon: '<i class="fa fa-file"></i>',
            allowedFileExtensions: ['jar'],
            maxFileCount: 50,
            maxFileSize: 500 * 1024   //单位kb，文件最大500M
        }).on('filebatchuploadsuccess', function (event, data, previewId, index) {
            // var rsp = data.response;
            // log.info("return urls：" + rsp.urls)
            // log.info("reutrn fileNames：" + rsp.fileNames)
            // log.info("reutrn newFileNames：" + rsp.newFileNames)
            // log.info("return originalFilenames：" + rsp.originalFilenames)
            // //数据库存放路径
            // $.ajax()
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
    });
</script>
</body>
</html>
